//
//  UI + Extension.swift
//  xinlangweibo
//
//  Created by 刘亮 on 15/10/16.
//  Copyright © 2015年 liuliang. All rights reserved.
//


//import UIKit
//
//extension UIButton {
//    
//    /// `便利`构造函数
//    convenience init(imageName: String, backImageName: String) {
//        self.init()
//        
//        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
//        setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
//        setBackgroundImage(UIImage(named: backImageName), forState: UIControlState.Normal)
//        setBackgroundImage(UIImage(named: backImageName + "_highlighted"), forState: UIControlState.Highlighted)
//        
//        // 会根据背景图片的大小调整尺寸
//        sizeToFit()
//    }
//}


import UIKit

extension UIButton{

    //‘便利’构造函数
    convenience init(imageName: String, backImageName: String){
        
       self.init()
    
//        //自定义样式的按钮
//        let button = UIButton()
//
        setImage(UIImage(named: imageName ), forState: UIControlState.Normal)
        
        setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        
        setBackgroundImage(UIImage(named: backImageName), forState:UIControlState.Normal)
        
        setBackgroundImage(UIImage(named:backImageName + "_highlighted"), forState:UIControlState.Highlighted)
        
        //会根据背景的大小调整尺寸
        sizeToFit()
  
    }

}